// Simple program to demonstrate the difference between passing
// arguments by value and by reference
#include <iostream>
#include <cmath>

double a = 3.0;
double b = -5.0; 
double c = 0.3;

void roots_value(double sp, double sm)
{
  sp = (-b + sqrt(b*b - 4*a*c))/2.0/a;
  sm = (-b - sqrt(b*b - 4*a*c))/2.0/a;
}

void roots_ref(double &sp, double &sm)
{
  sp = (-b + sqrt(b*b - 4*a*c))/2.0/a;
  sm = (-b - sqrt(b*b - 4*a*c))/2.0/a;
}

int main()
{
  double solnp = 0.0, solnm = 0.0;

  roots_value(solnp, solnm);
  std::cout << "roots_value solution = " << solnp << "  " << solnm << std::endl;

  roots_ref(solnp, solnm);
  std::cout << "roots_ref solution   = " << solnp << "  " << solnm << std::endl;

  return 0;
}
